package com.rykj.ruiyan_ptz.control

import com.rykj.common.utils.RYLogger
import com.rykj.socket_lib.SocketLib
import com.rykj.socket_lib.callback.UDPSocketCallBack
import com.rykj.socket_lib.entity.*

//#define PTZ_UP 0x00
//#define PTZ_DOWN 0x01
//#define PTZ_LEFT 0x00
//#define PTZ_RIGHT 0x01
class UDPManager private constructor() {
    companion object {
        private var instance: UDPManager? = null
            get() {
                if (field == null) {
                    field = UDPManager()
                }
                return field
            }

        fun get(): UDPManager {
            return instance!!
        }
    }

    private val socket: SocketLib = SocketLib();


    fun init(ipStr: String, port: Int) {
        socket.setCallBack(object : UDPSocketCallBack {
            override fun onDevInfoCallBack(devices: SkyNodeGndDevice) {
            }

            override fun onBaseInfoCallBack(baseInfo: SkyNodeGndBaseInfo) {

            }

            override fun onDetectInfoCallBack(detectInfoS: SkyNodeGndDetectInfoS) {

            }

            override fun onTrackInfoCallBack(trackInfo: SkyNodeGndTrackInfo) {

            }

            override fun onPIDCallBack(ptzPid: SkyNodeGndPTZPid) {
                RYLogger.i("--------------->" + ptzPid.pitchP.toString())
            }

            override fun onAlgParamInfoCallBack(algParams: SkyNodeGndAlgParams) {

            }

        })
        println(socket.stringFromJNI())
        socket.Start(ipStr, port)
        socket.QuerySetDev()
    }

    fun Stop() {
        socket.Stop()
    }

    fun PtzMove(direction: Int, type: Int, angle: Short, speed: Int) {
        socket.PtzMove(type, direction, angle, speed);
    }

    fun ZoomAction(dev_no: Int, direction: Int) {
        socket.ZoomAction(dev_no, direction)
    }
}